package com.demo.encodeDecode.base64;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;

/**
 *
 * Created by liangqingqing on 2018/5/11.
 */
@Slf4j
public class Client {

    public static void main(String[] args){

        //byte[] bytes = {0,1,4,21,111,127};
        //
        //String s = "00011001";
        ////String s = "127";
        //log.info("s：{}",Byte.valueOf(s,2));
        //log.info("s：{}",Byte.parseByte(s,2));
        //log.info("bytes：{}",bytes.toString());

        String str = "你好";
        log.info("原始字符串：{}",str);



        String encodeStr = Base64Util.encode(str);
        log.info("自己的编码结果：{}",encodeStr);

        String encodeStrByApache = Base64.encodeBase64String(str.getBytes());
        log.info("apache的编码结果：{}",encodeStr);




        String decodeStr = Base64Util.decode(encodeStr);
        log.info("自己的解码结果：{}",decodeStr);


        String decodeStrByApache = new String(Base64.decodeBase64(encodeStr));
        log.info("apache的解码结果：{}",decodeStrByApache);

    }
}
